package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.log.VerticalParkLogDao;
import com.tbit.main.pojo.VerticalParkLog;
import com.tbit.main.service.DataService;
import com.tbit.main.service.MachineService;
import com.tbit.main.service.VerticalParkLogService;
import com.tbit.main.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LMY
 * @create 2023-07-11 14:53
 */
@Service
public class VerticalParkLogServiceImpl implements VerticalParkLogService {

    @Autowired
    private VerticalParkLogDao verticalParkLogDao;
    @Autowired
    private DataService dataService;
    @Autowired
    private MachineService machineService;

    @Override
    public List<VerticalParkLog> getVertical(Integer accountId, Integer parkPointId, String userCode, Integer result, Integer enable) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, accountId);
        map.put("parkPointId", parkPointId);
        if (userCode != null) {
            map.put("machineNO", dataService.getMachineNO(userCode));
        }
        map.put("result", result);
        map.put("enable", enable);
        return verticalParkLogDao.getVertical(map);
    }

    @Override
    public void updateEnable(String machineNO) {
        verticalParkLogDao.updateEnable(machineNO);
    }

    @Override
    public List<VerticalParkLog> getMachineAccountId(Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, accountId);
        map.put("result", 0);
        map.put("enable", 1);
        return verticalParkLogDao.getMachineAccountId(map);
    }

    @Override
    public List<VerticalParkLog> getMachineRegionId(List<Integer> regionId) {
        Map<String, Object> map = new HashMap<>();
        map.put("regionId", StringUtil.getListString(regionId));
        map.put("result", 0);
        map.put("enable", 1);

        return verticalParkLogDao.getMachineAccountId(map);
    }
}
